// The code for player
// Max Bareiss 2009 GNU GPL
// You know what goes here
#include "player.h"
#ifndef SPRITES
#include "sprite.h"
#endif

Player::Player()
{
	x = 0;
	y = 0;
	acc_x = 0;
	acc_y = 0;
	rot = 0;
	shooting = false;
}
void Player::move (Uint8 *keystates)
{
	if (keystates[SDLK_UP] || keystates[SDLK_w])
	{
		acc_y += -0.5f;
	}
	else if (keystates[SDLK_DOWN] || keystates[SDLK_s])
	{
		acc_y += 0.5f;
	}
	if (keystates[SDLK_LEFT] || keystates[SDLK_a])
	{
		acc_x += -0.5f;
	}
	else if (keystates[SDLK_RIGHT] || keystates[SDLK_d])
	{
		acc_x += 0.5f;
	}
}

void Player::update()
{
	x += acc_x;
	y += acc_y;
	if (acc_x > 8) acc_x = 8;
	if (acc_x < -8) acc_x = -8;
	if (acc_y > 8) acc_y = 8;
	if (acc_y < -8) acc_y = -8;
	if (x < 0)
		x = 0;
	if (y < 0)
		y = 0;
	if (x > 1024)
		x = 1024;
	if (y > 768)
		y = 768;
}
